import request from "@/utils/request";
import Cookies from "js-cookie";

export function loginByPassword(data) {
  return request({
    url: '/auth/user/phonePasswordLogin',
    method: 'post',
    data
  })
}

export function loginByCaptcha(data) {
  return request({
    url: '/auth/user/phoneCaptchaLogin',
    method: 'post',
    data
  })
}

export function getCaptcha(data) {
  return request({
    url: '/auth/user/sendSmsCaptcha',
    method: 'get',
    params: data
  })
}

export function updatePasswordByCaptcha(data) {
  return request({
    url: '/auth/user/updatePasswordByCaptcha',
    method: 'put',
    data
  })
}

export function phoneCaptchaRegister(data) {
  return request({
    url: '/auth/user/phoneCaptchaRegister',
    method: 'post',
    data
  })
}

export function logout(data) {
  return request({
    url: '/auth/user/logout',
    method: 'get',
    params: data,
    headers: {
      "satoken": JSON.parse(Cookies.get("user_token")).tokenValue
    }
  })
}

export function checkPhone(data) {
  return request({
    url: '/auth/user/checkPhoneCaptcha',
    method: 'get',
    params: data
  })
}

export function updateUser(data) {
  return request({
    url: '/auth/user/updateUser',
    method: 'put',
    data
  })
}

export function updateEmail(data) {
  return request({
    url: '/auth/user/updateEmail',
    method: 'put',
    data
  })
}

export function sendEmailCaptcha(data) {
  return request({
    url: '/auth/user/sendEmailCaptcha',
    method: 'get',
    params: data
  })
}

export function getBaseInfoById(data) {
  return request({
    url: '/auth/user/query/baseInfoById/' + data.id,
    method: 'get',
    params: data
  })
}
